//
//  LCCommonTool.m
//  lcs_b
//
//  Created by chaiyanan on 15/6/2.
//  Copyright (c) 2015年 LC. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "LCCommonTool.h"

@implementation LCCommonTool

+(UILabel *)LabelWithRect:(CGRect)rect textColor:(UIColor *)color textstr:(NSString *)str textfont:(int)font textstyle:(NSTextAlignment)aligment superView:(UIView *)fatherView{
    UILabel *label = [[UILabel alloc] initWithFrame:rect];
    label.textColor = color;
    label.text = str;
    label.font = [UIFont systemFontOfSize:font];
    label.textAlignment = aligment;
    label.numberOfLines = 0;
    [fatherView addSubview:label];
    return label;
}

+(UITextField *)TextFieldWithRect:(CGRect)rect textColor:(UIColor *)color textstr:(NSString *)str placeHolderStr:(NSString *)placeHolderStr textfont:(int)font textstyle:(NSTextAlignment)aligment superView:(UIView *)fatherView{
    UITextField *textField = [[UITextField alloc] initWithFrame:rect];
    textField.borderStyle = UITextBorderStyleNone;
    textField.textColor = color;
    textField.text = str;
    textField.placeholder = placeHolderStr;
    textField.font = [UIFont systemFontOfSize:font];
    textField.textAlignment = aligment;
    [fatherView addSubview:textField];
    return textField;
}

+(UIButton *)ButtonWithRect:(CGRect)rect bgColor:(UIColor *)color textstr:(NSString *)str textfont:(int)font withTag:(NSInteger)tag superView:(UIView *)fatherView andTarget:(id)target  action:(SEL)action
{
    return [self ButtonWithRect:rect bgColor:color textColor:[UIColor whiteColor] textstr:str textfont:font withTag:tag superView:fatherView andTarget:target action:action];
}

+(UIButton *)ButtonWithRect:(CGRect)rect bgColor:(UIColor *)color textColor:(UIColor *)textColor textstr:(NSString *)str textfont:(int)font withTag:(NSInteger)tag superView:(UIView *)fatherView andTarget:(id)target action:(SEL)action
{
    return [self ButtonWithRect:rect bgColor:color textColor:[UIColor whiteColor] textstr:str textfont:font textAlignment:UIControlContentHorizontalAlignmentCenter withTag:tag superView:fatherView andTarget:target action:action];
}

+(UIButton *)ButtonWithRect:(CGRect)rect bgColor:(UIColor *)color textColor:(UIColor *)textColor textstr:(NSString *)str textfont:(int)font textAlignment:(UIControlContentHorizontalAlignment)aligment withTag:(NSInteger)tag superView:(UIView *)fatherView andTarget:(id)target action:(SEL)action
{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = rect;
    button.backgroundColor = color;
    [button setTitleColor:textColor forState:UIControlStateNormal];
    [button setTitle:str forState:UIControlStateNormal];
    button.contentHorizontalAlignment = aligment;
    button.titleLabel.font = [UIFont systemFontOfSize:font];
    button.tag = tag;
    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    [fatherView addSubview:button];
    return button;
}

+(UIView *)ImageLineWithRect:(CGRect)rect textColor:(UIColor *)color superView:(UIView *)fatherView{
    UIView *aView = [[UIView alloc] initWithFrame:rect];
    aView.backgroundColor = color;
    [fatherView addSubview:aView];
    return aView;
}

+(UIImageView *)ImageViewWithRect:(CGRect)rect imageName:(NSString *)imageName contentMode:(UIViewContentMode)contentMode superView:(UIView *)fatherView
{
    UIImageView *aView = [[UIImageView alloc] initWithFrame:rect];
    aView.image = [UIImage imageNamed:imageName];
    aView.contentMode = contentMode;
    [fatherView addSubview:aView];
    return aView;
}

@end
